From: Brion Vibber Date: Wed, 27 Apr 2005 01:16:47 +0000 (+0000) Subject: Restore correct e-mail confirmation code brutally removed by incorrect merge in revis... X-Git-Tag: 1.5.0alpha1~113 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=ec6e998fc08cdc01ef032fafacffd2309c9d9102;p=lhc%2Fweb%2Fwiklou.git Restore correct e-mail confirmation code brutally removed by incorrect merge in revision 1.101. --- diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 0aa9f09890..bed62bd9cb 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -236,32 +236,31 @@ class PreferencesForm { $wgUser->setCookies(); $wgUser->saveSettings(); + $error = wfMsg( 'savedprefs' ); if( $wgEnableEmail ) { - $newadr = strtolower( $this->mUserEmail ); - $oldadr = strtolower($wgUser->getEmail()); - if (($newadr <> '') && ($newadr <> $oldadr)) { # the user has supplied a new email address on the login page - # prepare for authentication and mail a temporary password to newadr - require_once( 'SpecialUserlogin.php' ); - if ( !$wgUser->isValidEmailAddr( $newadr ) ) { - $this->mainPrefsForm( wfMsg( 'invalidemailaddress' ) ); - return; - } - $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record - $wgUser->mEmailAuthenticationtimestamp = 0; # but flag as "dirty" = unauthenticated - $wgUser->saveSettings(); - if ($wgEmailAuthentication) { - # mail a temporary password to the dirty address - # on "save options", this user will be logged-out automatically - $error = LoginForm::mailPasswordInternal( $wgUser, true, $dummy ); - if ($error === '') { - return LoginForm::mainLoginForm( wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ) ); - } else { - return LoginForm::mainLoginForm( wfMsg( 'mailerror', $error ) ); + $newadr = $this->mUserEmail; + $oldadr = $wgUser->getEmail(); + if( ($newadr != '') && ($newadr != $oldadr) ) { + # the user has supplied a new email address on the login page + if( $wgUser->isValidEmailAddr( $newadr ) ) { + $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record + $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated + $wgUser->saveSettings(); + if ($wgEmailAuthentication) { + # Mail a temporary password to the dirty address. + # User can come back through the confirmation URL to re-enable email. + $result = $wgUser->sendConfirmationMail(); + if( WikiError::isError( $result ) ) { + $error = wfMsg( 'mailerror', $result->getMessage() ); + } else { + $error = wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() ); + } } - # if user returns, that new email address gets authenticated in checkpassword() + } else { + $error = wfMsg( 'invalidemailaddress' ); } } else { - $wgUser->setEmail( strtolower($this->mUserEmail) ); + $wgUser->setEmail( $this->mUserEmail ); $wgUser->setCookies(); $wgUser->saveSettings(); }